interface Shape {
    draw(): void;
}

class Rectangle implements Shape {
    public draw(): void {
        console.log('▲');
    }
}

class Circle implements Shape {
    public draw(): void {
        console.log('●');
    }
}


abstract class ShapeDecorator implements Shape {
    protected shape: Shape;
    public constructor(shape: Shape) {
        this.shape = shape;
    }
    public abstract draw(): void;
}

class RedShapeDecorator extends ShapeDecorator {
    public constructor(shape: Shape) {
        super(shape);
    }
    public override draw(): void {
        this.shape.draw();
        this.setRedBorder(this.shape);
    }
    private setRedBorder(_: Shape): void {
        console.log('Border Color: Red');
    }
}

class BlueShapeDecorator extends ShapeDecorator {
    public constructor(shape: Shape) {
        super(shape);
    }
    public override draw(): void {
        this.shape.draw();
        this.setBlueBorder(this.shape);
    }
    private setBlueBorder(_: Shape): void {
        console.log('Border Color: Blue');
    }
}

function main() {
    const circle: Shape = new Circle();
    const redCircle: ShapeDecorator = new RedShapeDecorator(circle);
    redCircle.draw();
    const blueCircle: ShapeDecorator = new BlueShapeDecorator(circle);
    blueCircle.draw();

    const rectangle: Shape = new Rectangle();
    const redRectangle: ShapeDecorator = new RedShapeDecorator(rectangle);
    redRectangle.draw();
    const blueRectangle: ShapeDecorator = new BlueShapeDecorator(rectangle);
    blueRectangle.draw();
}

main();
